# _*_ coding: utf-8 _*_
# @Author   : Wei Yue
# @Time     : 2024-09-05 16:09
# @Function :
import os
from datetime import datetime
from enum import Enum

ACTIVE_PARAGRAPHS = 6
DUE_DAYS = 7
IMAGES_LIMIT = 3
START_TIME = datetime(2024, 9, 23)
WECHAT_PAGE = 1


class WechatPublic:
    def __init__(self, name, cookie=None, fake_id=None, token=None):
        self.name = name
        self.cookie = cookie
        self.fake_id = fake_id
        self.token = token
        self.data = None

    def refreshData(self):
        self.data = {
            "token": self.token,
            "lang": "zh_CN",
            "f": "json",
            "ajax": "1",
            "action": "list_ex",
            "begin": "0",
            "count": "5",
            "query": "",
            "fakeid": self.fake_id,
            "type": "9",
        }

    def __str__(self):
        return f"{self.name} - {self.fake_id} - {self.token}"


class CarTopics(Enum):
    OEM = "整车OEM"
    POLICY_ANALYSIS = "政策分析"
    ELECTRIC_DRIVE = "电驱产品"
    FRONTIER_TECH = "前沿技术"
    INTERNATIONAL_VIEW = "国际视野"
    MARKET_INFO = '市场信息'
    WECHAT_PUBLIC = '公众号资讯'


DIR = os.path.abspath(os.path.dirname(__file__))
PROJECT_DIR = os.path.abspath(os.path.join(DIR, os.pardir)).replace('\\', '/')

HEADERS = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
}

USER_AGENT_LIST = [
    'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
    'Chrome/45.0.2454.85 Safari/537.36 115Browser/6.0.3',
    'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
    'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
    'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
    'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0',
    'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
    "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Mobile Safari/537.36",
]

SEARCHWORDS = [
    '三合一电驱',
    '800V电机',
    '碳化硅',
    '销量',
    '汽车出海',
    '氮化镓',
    '悬架',
    '创维',
    '开沃',
    '极石',
    '洛轲智能',
]

SEARCHWORDS_TOPICS = {
    '三合一电驱': CarTopics.ELECTRIC_DRIVE,
    '800V电机': CarTopics.ELECTRIC_DRIVE,
    '碳化硅': CarTopics.FRONTIER_TECH,
    '销量': CarTopics.MARKET_INFO,
    '汽车出海': CarTopics.MARKET_INFO,
    '氮化镓': CarTopics.FRONTIER_TECH,
    '悬架': CarTopics.FRONTIER_TECH,
    '创维': CarTopics.OEM,
    '开沃': CarTopics.OEM,
    '极石': CarTopics.OEM,
    '洛轲智能': CarTopics.OEM,

}

WANG_CAI_DLZC = WechatPublic('智驭动力系统')
WANG_CAI_DLZC.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
WANG_CAI_DLZC.fake_id = "MzU4MDY1Mzk2Nw=="
WANG_CAI_DLZC.token = "233948893"
WANG_CAI_DLZC.refreshData()

WANG_CAI_DJYDK = WechatPublic('旺材电机与电控')
WANG_CAI_DJYDK.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
WANG_CAI_DJYDK.fake_id = "MzI0MDU0NDMyMQ=="
WANG_CAI_DJYDK.token = "233948893"
WANG_CAI_DJYDK.refreshData()

XI_MO_DJQ = WechatPublic('西莫电机圈')
XI_MO_DJQ.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
XI_MO_DJQ.fake_id = "MzIyNjI3NTgwOA=="
XI_MO_DJQ.token = "233948893"
XI_MO_DJQ.refreshData()

GAI_SHI_QCSQ = WechatPublic('盖世汽车社区')
GAI_SHI_QCSQ.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
GAI_SHI_QCSQ.fake_id = "MjM5MDc2ODM0MA=="
GAI_SHI_QCSQ.token = "233948893"
GAI_SHI_QCSQ.refreshData()

RIO = WechatPublic('RIO电驱动')
RIO.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
RIO.fake_id = "MzU2NDc3NDI2Mg=="
RIO.token = "233948893"
RIO.refreshData()

CHUANGWEI = WechatPublic('创维汽车')
CHUANGWEI.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
CHUANGWEI.fake_id = "MzI5NjkxNjAzOA=="
CHUANGWEI.token = "233948893"
CHUANGWEI.refreshData()

JISHI = WechatPublic('极石汽车')
JISHI.cookie = 'appmsglist_action_3935798870=card; ua_id=nATcvOUnwCR5jx0SAAAAAPKFh7xExV1Pi1d7mX9Jc3k=; wxuin=27798059022871; mm_lang=zh_CN; _clck=3935798870|1|fqd|0; uuid=cb639398df63d2728a03fc73a94a624d; rand_info=CAESINnRYWorE1wpQ+YzKYzhzdFceRfD9WFhNjzTJ7lGfWNe; slave_bizuin=3935798870; data_bizuin=3935798870; bizuin=3935798870; data_ticket=ud/cRuQGQqq5x+IYv7u0az/zUxpPXNzxragCaXRVvgdmykxxrpEUazz7q/ndKj3X; slave_sid=VEJXWlZZRFZaUXk4dE51akZUSnU5VHRwanh0bzlfZlpyRTRsRnlGeThkTklnWUplVUw5bGFDVmt2cEJQSlpfdElWYlhKanNfQnlTZkRDVnpwbHNmUFpESlpjakM1ZXhkcVNEMHQwZ1d3dU01S0dCUmdhMmZWaEpEUDhTbTdQZXRoaHJSTGtEbGYyWUVIQVV1; slave_user=gh_d860cb7e081e; xid=7c9fa473e8b2c23260872411d8c0e530; _clsk=q8z1py|1730044623553|4|1|mp.weixin.qq.com/weheat-agent/payload/record'
JISHI.fake_id = "Mzk0MzUyNTY3NQ=="
JISHI.token = "233948893"
JISHI.refreshData()